#!/usr/bin/env python3
"""
FastAPI平台启动脚本
"""

import sys
import os
from dotenv import load_dotenv

# 将backend目录添加到Python路径，以便能导入settings
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

# 加载环境变量
load_dotenv()

if __name__ == "__main__":
    # 启动FastAPI应用
    from uvicorn import run
    
    # 导入统一的配置
    from settings import settings
    
    # 从统一配置中获取服务器设置
    host = settings.server.HOST
    port = settings.server.PORT
    reload = settings.server.RELOAD
    
    # 打印启动信息
    print(f"Starting FastAPI server on {host}:{port}")
    print(f"Reload mode: {reload}")
    
    # 启动应用
    run(
        "app.main:app",
        host=host,
        port=port,
        reload=reload,
        reload_dirs=["app"] if reload else None,
        reload_excludes=["*.log", "*.sql", "*.pyc", ".git/", "__pycache__/"],
        access_log=True
    )

